package com.lagou.demo.controller;

import com.lagou.demo.service.IDemoService;
import com.lagou.edu.mvcframework.annotations.LagouAutowired;
import com.lagou.edu.mvcframework.annotations.LagouController;
import com.lagou.edu.mvcframework.annotations.LagouRequestMapping;
import com.lagou.edu.mvcframework.annotations.Security;

/**
 * 权限控制的接口类
 * @author yingchengpeng
 */
@Security({"xiaoming", "xiaoli"})
@LagouController
@LagouRequestMapping("/security/demo")
public class SecurityDemoController {

    @LagouAutowired
    private IDemoService demoService;

    /**
     * 小张专属接口
     *
     * @param username 用户名
     * @return 返回信息
     */
    @Security(value = {"xiaozhang"})
    @LagouRequestMapping("/xiaozhang")
    public String xiaozhang(String username) {
        return demoService.sayHello(username, "本接口覆盖类的权限，专属于小张");
    }


    /**
     * @param username 用户名
     * @return 返回信息
     */
    @LagouRequestMapping("/double")
    public String doublePerson(String username) {
        return demoService.sayHello(username, "本接口权限继承接口类，专属于小明和小李");
    }


    /**
     * 小李专属接口
     *
     * @param username 用户名
     * @return 返回信息
     */
    @Security(value = {"xiaoli"})
    @LagouRequestMapping("/xiaoli")
    public String xiaoli(String username) {
        return demoService.sayHello(username, "本接口权限限制类的权限，专属于小李");
    }

}
